# 1.导包
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

# 2.创建浏览器驱动对象
# Firefox浏览器:
# driver = webdriver.Firefox()
# Chrome浏览器:
path = r"D:\Programs\Python\Python313\chromedriver.exe"
ser = Service(executable_path = path)
driver = webdriver.Chrome(service = ser)
# 使用Edge浏览器,不需要安装驱动
# driver = webdriver.Edge ()
time.sleep(3)
# 3.打开Web页面
driver.get("http://hmshop-test.itheima.net/")
# 4.页面操作,tpshop的登录
# 4.1 进入登录页面
driver.find_element(by=By.LINK_TEXT, value="登录").click()
# 4.2 输入信息
driver.find_element(by=By.ID, value="username").send_keys("13400000000")
driver.find_element(by=By.ID, value="password").send_keys("123456")
driver.find_element(by=By.ID, value="verify_code").send_keys("8888")
driver.find_element(by=By.LINK_TEXT, value="登    录").click()
# 写断言进行判断
time.sleep(3)
result = driver.find_element(by=By.CSS_SELECTOR, value=".red.userinfo").text

assert "13400000000" == result


# 5.暂停
time.sleep(3)
# .关闭浏览器驱动对象
driver.quit()
